						  /****** Object:  Stored Procedure [dbo].spPhieuXuatGetList Script Date: 6/12/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spPhieuXuatGetListByPhieuGiao]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spPhieuXuatGetListByPhieuGiao]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		01/07/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spPhieuXuatGetListByPhieuGiao]
(
 @HavePhieuGiao bit
)

WITH ENCRYPTION
AS

if(@HavePhieuGiao=0)
begin
SELECT
	*
FROM
	[tbl_PhieuXuat]
WHERE
	SoPX not in (select SoPX from tbl_phieuGiaoHang)
end
else
SELECT
	*
FROM
	[tbl_PhieuXuat]
WHERE
	SoPX in (select SoPX from tbl_phieuGiaoHang)
GO

--GRANT EXECUTE ON [dbo].[spPhieuXuatGetList] TO [sa]
--GO
